
cc.Class({
    extends: cc.Component,

    properties: {
        // 兽人
        orc: {
            default: null,
            type: cc.Prefab
        },
    },

    createOrc() {
        for (let index = 1; index <= 10; index++) {
            let orc = cc.instantiate(this.orc);
            orc.y = 0;
            orc.x = this.node.width / 10 * index;
            orc.parent = this.node;
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        const managerCollis = cc.director.getCollisionManager();
        managerCollis.enabled = true;
         // 开启碰撞系统的调试线框绘制
        managerCollis.enabledDebugDraw = true;
        managerCollis.enabledDrawBoundingBox = true;

        // this.orcLeft = cc.instantiate(this.orc);
        // this.orcLeft.y = 0;
        // this.orcLeft.x = -this.node.width / 2 + this.orcLeft.width / 2;
        // this.orcLeft.parent = this.node;

        // this.orcRight = cc.instantiate(this.orc);
        // this.orcRight.y = 0;
        // this.orcRight.x = this.node.width / 2 - this.orcRight.width / 2;
        // this.orcRight.parent = this.node;
        // this.orcRight.color = cc.color(255, 0, 0, 255);
    },

    start() {
        this.node.on('touchstart', () => {
            this.createOrc();
            // let moveLength = this.node.width / 2 - this.orcLeft.width;

            // let moveRigh = cc.moveBy(3, cc.v2(moveLength / 2, 0));
            // this.orcLeft.runAction(moveRigh);

            // let moveLeft = cc.moveBy(3, cc.v2(-moveLength / 2, 0));
            // this.orcRight.runAction(moveLeft);

        }, this);
    },

}); 
